//题目链接：https://www.luogu.com.cn/problem/P3386#submit
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 10100 , M = 50100;
int h[N],e[M],ne[M],idx;
bool st[N];
int match[N];
int n1 , n2 , m;

void add(int a , int b)
{
    e[idx] = b , ne[idx] = h[a] , h[a] = idx++;
}

bool find(int x)
{
    for(int i = h[x] ; i != -1 ; i = ne[i])
    {
        int j = e[i];
        if(!st[j])
        {
            st[j] = true;
            if(match[j] == 0 || find(match[j]))
            {
                match[j] = x;
                return true;
            }
        }
    }
    return false;
}
int main()
{
    scanf("%d%d%d",&n1,&n2,&m);
    memset(h,-1,sizeof h);
    for(int i = 0 ; i < m ; ++i)
    {
        int a , b;
        scanf("%d%d",&a,&b);
        add(a,b);
    }
    int res = 0;
    for(int i = 1 ; i <= n1 ; ++i)
    {
        memset(st,0,sizeof st);
        if(find(i)) res++;
    }
    printf("%d",res);
    return 0;
}